import { useGlobalStore } from "@stores";
import router from "@router";

import { getInfo } from "@api/user";

export const useUserInfo = async (data: string) => {
  // 存token
  useGlobalStore().userStore.setToken(data);
  //   获取用户信息
  const res = await getInfo();
  useGlobalStore().userStore.setInfo(res.data);
  // 关闭登录弹窗
  router.app.config.globalProperties.$hideLoginDialog();
};

// 错误：不能写在useUserInfo外面
// const globalStore = useGlobalStore();
// const userStore = globalStore.userStore;
